<template>
  <div >
        <zh-row>
            <zh-col :span="8">
              <FileClassTree ref="classTreeRef" @nodeClick="getClassInfo">
              </FileClassTree>
            </zh-col>

            <zh-col :span="16">
              <zh-card title="授权信息">
              <div>
                <zh-form ref="formRef" :md="24" :lg="24" :xl="24"  :model="fileAppReadInfo" :rules="rules" labelWidth="120">
                  <zh-form-input prop="fileClassCode" label="文件分类编码"  v-model="fileAppReadInfo.fileClassCode" v-if="false"
                                disabled></zh-form-input>
                                
                  <zh-form-input prop="classTitle" label="分类标题"  v-model="fileAppReadInfo.classTitle" v-if="false"
                                disabled></zh-form-input>
                  <zh-form-select
                      prop="appId"
                      :lazy="true"
                      label="所属应用"
                      v-model="fileAppReadInfo.appId"
                      :fieldNames="{ label: 'appName', value: 'appId' }"
                      funcCode="application0012"
                      :disabled="props.displayFlag"
                      searchField="appName"
                  ></zh-form-select>

                  <zh-form-select
                            prop="secrecyLevel"
                            label="保密级别"
                            allowClear 
                            :options="state.dictData.SECRECYLEVEL"
                            v-model="fileAppReadInfo.secrecyLevel"
                        ></zh-form-select>      
                
                  <zh-form-date
                                prop="expireTime"
                                label="到期时间"
                                placeholder="请输入到期时间"
                                type="datetime"
                                v-model="fileAppReadInfo.expireTime"
                              ></zh-form-date>
                  <!-- <zh-button style="margin-left: 700px" buttonType="add" @click="test">test</zh-button> -->
                </zh-form>
              </div>
            </zh-card>
            </zh-col>
        </zh-row>
  </div>


    
</template>

<script lang="ts" setup name="fileAppReadInfo">
import ZhForm from "@/components/zh-form/index.vue";
import FileClassTree from '@/views/fileCenter/fileApply/component/FileClassTree.vue';

// ------------------变量区------------------------------
const classTreeRef=ref();
const props = defineProps({
  scrollHeight: {
    type: String,
    default: ''
  },
  displayFlag: {
    type: Boolean,
    default:false
  },
});
const formRef = ref<any>();
const fileAppReadInfo = ref<any>({
});
const state = reactive({
  dictData:[] as any
});

const rules = reactive({
  fileClassCode: [
    {
      required: true,
      message: '文件分类编码为空',
      trigger: 'blur',
    },
  ],
  appId: [
    {
      required: true,
      message: '请选择需要授权的应用',
      trigger: 'blur',
    },
  ],
  secrecyLevel: [
    {
      required: true,
      message: '请选择保密级别',
      trigger: 'blur',
    },
  ],
  expireTime: [
    {
      required: true,
      message: '请选择过期时间',
      trigger: 'blur',
    },
  ]
});


//------------------初始化------------------------------
const params = {
  dictFields: 'status,flag,SECRECYLEVEL',
};
$api.common.getBatchDict.post(params).then((res) => {
  state.dictData = res.result;
});

//--------------------------定义调用方法--------------------------------------------------
// function setInitData(info) {
//   formRef.value?.resetFields();
//   if (info) {
//     fileAppReadInfo.value=info;
//   }
// }

function getClassInfo(){
  console.log('节点:'+classTreeRef.value.selectNode.title)
  //获取当前树选中的节点
  fileAppReadInfo.value.fileClassCode=classTreeRef.value.selectNode.key;
  fileAppReadInfo.value.classTitle=classTreeRef.value.selectNode.title;
}

function getCheckedKeys(){
  // console.log("aaa")
  return classTreeRef.value.getCheckedKeys();
}


//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({fileAppReadInfo,classTreeRef,getCheckedKeys});
</script>
